﻿CREATE TABLE [dbo].[ProjectTask] (
    [TaskId]              UNIQUEIDENTIFIER NOT NULL,
    [Name]                NVARCHAR (500)   NOT NULL,
    [ProjectId]           UNIQUEIDENTIFIER NOT NULL,
    [ProjectIterationId]  UNIQUEIDENTIFIER NULL,
    [StatusCode]          INT              NULL,
    [StartDate]           DATETIME         NULL,
    [EndDate]             DATETIME         NULL,
    [Description]         NVARCHAR (MAX)   NULL,
    [QuoteWorkHours]      FLOAT (53)       NULL,
    [ActualWorkHours]     FLOAT (53)       NULL,
    [ActualInput]         FLOAT (53)       NULL,
    [Effort]              FLOAT (53)       NULL,
    [Overtime]            FLOAT (53)       NULL,
    [EvaluateExactlyRate] FLOAT (53)       NULL,
    [InputEffortRate]     FLOAT (53)       NULL,
    [RemainderTime]       FLOAT (53)       NULL,
    [OwnerId]             UNIQUEIDENTIFIER NULL,
    [CreatedOn]           DATETIME         NULL,
    [CreatedById]         UNIQUEIDENTIFIER NULL,
    [ModifiedOn]          DATETIME         NULL,
    [ModifiedById]        UNIQUEIDENTIFIER NULL,
    [IsDeleted]           BIT              NOT NULL,
    [VersionNumber]       ROWVERSION       NULL,
    [PriorityCode]        INT              NULL,
    CONSTRAINT [PK_ProjectTask] PRIMARY KEY CLUSTERED ([TaskId] ASC),
    CONSTRAINT [FK_ProjectTask_Project] FOREIGN KEY ([ProjectId]) REFERENCES [dbo].[Project] ([ProjectId]),
    CONSTRAINT [FK_ProjectTask_ProjectIteration] FOREIGN KEY ([ProjectIterationId]) REFERENCES [dbo].[ProjectIteration] ([ProjectIterationId]),
    CONSTRAINT [FK_ProjectTask_User] FOREIGN KEY ([OwnerId]) REFERENCES [dbo].[User] ([UserId]),
    CONSTRAINT [FK_ProjectTask_User_CreatedBy] FOREIGN KEY ([CreatedById]) REFERENCES [dbo].[User] ([UserId]),
    CONSTRAINT [FK_ProjectTask_User_ModifiedBy] FOREIGN KEY ([ModifiedById]) REFERENCES [dbo].[User] ([UserId])
);

